﻿{% extends "gma/base.html" %}
{% load mytag %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__bd">
    <div class="weui-panel weui-panel_access">
        <div class="weui-panel__hd"> 通话记录 (#{{ log.id }} ) </div>
        <div class="weui-panel__bd">
            <div class="weui-media-box weui-media-box_appmsg">
                <a class="weui-media-box__hd" href="{% url 'gma:caster_detail' caller.uid %}">
                    <img class="weui-media-box__thumb avatar" src="{{ caller.avatar|cdn }}" alt="">
                </a>

                <i class="fa fa-phone-volume"></i>
                &nbsp; &nbsp;
                <a class="weui-media-box__hd" href="{% url 'gma:caster_detail' callee.uid %}">
                    <img class="weui-media-box__thumb avatar" src="{{ callee.avatar|cdn }}" alt="">
                </a>

                <div class="weui-media-box__bd">
                    <p class="weui-media-box__desc"> {{ log.begin_time|date:"H:i:s" }}~{{ log.end_time|date:"H:i:s" }} </p>
                    <p class="weui-media-box__desc">时长: {{ log.chat_seconds|readable_seconds }} </p>

                    {% if log.status == 1 %}
                        <p class="weui-media-box__desc"> <span class="blue_color">{{ log.status|call_status }}</span></p>
                    {% elif log.status == 2 %}
                        <p class="weui-media-box__desc"> <span class="red_color">{{ log.status|call_status }}</span></p>
                    {% elif log.status == 3 %}
                        <p class="weui-media-box__desc"> <span class="yellow_color">{{ log.status|call_status }}</span></p>
                    {% elif log.status == 4 %}
                        <p class="weui-media-box__desc">
                            <span class="green_color">{{ log.status|call_status }}</span>
                            {% if log.terminator_is_caster %}
                                <span class="red_color">(主播挂断)</span>
                            {% endif %}
                        </p>
                    {% else %}
                        <p class="weui-media-box__desc">状态: {{ log.status|call_status }} </p>
                    {% endif %}

                    {% if log.has_refund != 0 %}
                        <p class="weui-media-box__desc"> <span class="red_color"> <i class="fa fa-money-bill-alt"></i> 已退款! </span></p>
                    {% endif %}
                </div>

                <div class="weui-cell__ft">
                    {% if log.expense > 0 %}
                        <div>
                            {% if log.has_refund != 0 %}
                                <span class="red_color">{{ log.expense }} <i class="fa fa-gem"></i></span>
                            {% else %}
                                {{ log.expense }} <i class="fa fa-gem"></i>
                            {% endif %}
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>

        {% if permissions.view_video_log.open %}
            {% if log.chatlog_url %}
        <div align="center">
            <video class="pp-video" src="{{ log.chatlog_url|cdn }}" controls="controls">
            您的浏览器不支持 video 标签。
            </video>
        </div>
        {% endif %}
            {% endif %}
    </div>
</div>

<div class="weui-btn-area">
{% if permissions.refund.open %}
    {% if log.has_refund == 0 %}
        {% if log.expense > 0 %}
        <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:refund()"> <i class="fa fa-undo"></i> 退还费用 {{ log.expense }}<i class="fa fa-gem"></i> </a>
        {% endif %}
    {% endif %}
{% endif %}
{% if permissions.review.open %}
    {% if log.review == 0 %}
        <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:review()"> <i class="fa fa-eye"></i> 内容审核 </a>
    {% else %}
        <a class="weui-btn weui-btn_block weui-btn_primary" href="javascript:unreview()"> <i class="fa fa-eye"></i> 取消审核 </a>
    {% endif %}
{% endif %}
</div>

<div class="page__ft">
    <a href="{% url 'gma:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>

{% endblock content %}


<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script>

{% if permissions.refund.open %}
function refund() {
    show_confirm_dialog('通话退款', '你确定要退还"{{ log.expense }}"钻石给用户吗?', ()=> {
        let url = "{% url 'gma:api_refund_video_chat' %}";
        let data = {
            'liveid': {{ log.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`成功退款!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}
{% endif %}

{% if permissions.review.open %}
function review() {
    show_confirm_dialog('内容审核', '你确定要审核改视频吗?', ()=> {
        let url = "{% url 'gma:api_review_video_chat' %}";
        let data = {
            'liveid': {{ log.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`视频进入审核状态!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function unreview() {
    show_confirm_dialog('取消审核', '你确定要取消对改视频的审核吗?', ()=> {
        let url = "{% url 'gma:api_unreview_video_chat' %}";
        let data = {
            'liveid': {{ log.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`视频取消审核!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}
{% endif %}

</script>

{% endblock extra_js %}